// SqliteHelper.cpp : main source file for SqliteHelper.exe
//

////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2009  Jake Lin.  All Rights Reserved. http://procoder.cnblogs.com
//
//
// Based on wrapper written by Tyushkov Nikolay
// http://softvoile.com/development/CppSQLite3U/
// 
////////////////////////////////////////////////////////////////////////////////


#include "stdafx.h"

#include <atlframe.h>
#include <atlctrls.h>
#define _WTL_CE_NO_ZOOMSCROLL
#define _WTL_CE_NO_FULLSCREEN
#include <atlwince.h>

#include "resourceppc.h"

#include "AboutDlg.h"
#include "SqliteHelperDialog.h"

#include "../CppUnitLite/TestHarness.h"

//Unit Test Casese
#include "SqliteHelperTest.h"

CAppModule _Module;

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	//Unit Test
	TestResult tr("TestResult.txt");
    TestRegistry::runAllTests(tr);

	HRESULT hRes = CSqliteHelperDialog::ActivatePreviousInstance(hInstance, lpstrCmdLine);

	if(FAILED(hRes) || S_FALSE == hRes)
	{
		return hRes;
	}

	hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	AtlInitCommonControls(ICC_DATE_CLASSES);
	SHInitExtraControls();

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = CSqliteHelperDialog::AppRun(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}

